﻿using UnityEngine;
using System.Collections;
using System.Threading;

public class AniGroup : AniBean {

	public AniBase[] aniBasies;

	protected int aniEffectIndex;
	
	public override void playCallBack (CallBack callBack) {
		base.playCallBack(callBack);
		playCallBackGroup();
	}

	protected void playCallBackGroup() {
		if(aniBasies != null) {
			if(aniEffectIndex < aniBasies.Length) {
				AniBase aniBase = aniBasies[aniEffectIndex];
				if(aniBase != this) {
					++aniEffectIndex;
					playGroupAniBase(aniBase);
					return;
				}
			}
		}
		
		playComplete();
	}

	protected virtual void playGroupAniBase(AniBase aniBase) {
		aniBase.playCallBack(playCallBackGroup);
	}
}
